/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.lcfgly.Cache;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * service耗时统计
 * @author lcfgly
 */
@Component
@Aspect
public class TimeCountAop {
    
    Logger log=Logger.getLogger("ServiceTimeConsuming");
    
    @Around("execution(* com.lcfgly.Service.*.*(..))")  
    public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable{  
        Long start=System.currentTimeMillis();
        Object object = pjp.proceed();//执行该方法  
        log.info(pjp.getTarget().getClass()+"方法: "+pjp.getSignature().getName()+" 耗时: "+(System.currentTimeMillis()-start)+" 毫秒");
        return object;  
    }  
    
}
